////
////  NotiSettingVC.m
////  FishTank
////
////  Created by Scott Zhu on 1/21/15.
////  Copyright (c) 2015 Scott Zhu. All rights reserved.
////
//
//#import "NotiSettingVC.h"
//#import "DeviceSun.h"
//#import "APIs.h"
//
//@interface NotiSettingVC ()
//@property (strong, nonatomic) UIPickerView *pickerView;
//@property (strong, nonatomic) UIAlertView *tempPickerAlertView;
//@property (strong, nonatomic) NSArray *pickerViewData;
//@end
//
//@implementation NotiSettingVC
//@synthesize confirmButton = _confirmButton;
//@synthesize cancelButton = _cancelButton;
//@synthesize highTempButton = _highTempButton;
//@synthesize lowTempButton = _lowTempButton;
//- (void)viewDidLoad {
//    [super viewDidLoad];
//    
//    
//    DeviceSun * device = [DeviceSun defaultDevice];
//    //高温报警温度
//    [self.highTempButton setTitle:[NSString stringWithFormat:@"%d度", device.high] forState:UIControlStateNormal];
//    //低温报警温度
//    [self.lowTempButton setTitle:[NSString stringWithFormat:@"%d度", device.low] forState:UIControlStateNormal];
//    
//    
//    //备用电源状态
//    self.standbyPowerImage.image = [UIImage imageNamed:(device.standbyPower < 1 ? @"设定_22":@"设备报警设定_23")];
//    //紫外线灯
//    self.lampImage.image = [UIImage imageNamed:(device.lamp < 1 ? @"设定_24":@"设备报警设定_21")];
//    //冲浪水泵
//    self.waterPump.image = [UIImage imageNamed:(device.waterPump < 1 ? @"设定_26":@"设备报警设定_17")];
//    //灯光照明
//    self.floodLightImge.image = [UIImage imageNamed:(device.floodlight < 1 ? @"设定_28":@"设备报警设定_14")];
//    
//    _confirmButton.layer.cornerRadius = 4;
//    _cancelButton.layer.cornerRadius = 4;
//    _cancelButton.layer.borderWidth = 1;
//    _cancelButton.layer.borderColor = [UIColor grayColor].CGColor;
//    
//    
//    
//    [_confirmButton addTarget:self action:@selector(confirmAction:) forControlEvents:UIControlEventTouchUpInside];
//    [_cancelButton addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
//}
//- (void)confirmAction:(UIButton *)button{
//    NSLog(@"确定");
//    [self.navigationController popViewControllerAnimated:YES];
//}
//
//
//- (void)cancelAction:(UIButton *)button{
//    NSLog(@"取消");
//    [self.navigationController popViewControllerAnimated:YES];
//}
//
//
//- (void)didReceiveMemoryWarning {
//    [super didReceiveMemoryWarning];
//    // Dispose of any resources that can be recreated.
//}
//
//
//#pragma -mark- Actions
//- (IBAction)highTempButtonpressed:(id)sender
//{
//    [self.timePickerAlertView setTitle:@"高温报警设置"];
//    [self.timePickerAlertView setTag:0];
//    [self.timePickerAlertView show];
//}
//
//- (IBAction)lowTempButtonpressed:(id)sender
//{
//    [self.timePickerAlertView setTitle:@"低温报警设置"];
//    [self.timePickerAlertView setTag:1];
//    [self.timePickerAlertView show];
//}
//
//#pragma -mark- Setter and Getter
//-(UIAlertView *)timePickerAlertView
//{
//    if (!_tempPickerAlertView)
//    {
//        _tempPickerAlertView = [[UIAlertView alloc] initWithTitle:@""
//                                                          message:@""
//                                                         delegate:self
//                                                cancelButtonTitle:@"取消"
//                                                otherButtonTitles:@"确定", nil];
//        [_tempPickerAlertView setValue:self.pickerView forKey:@"accessoryView"];
//    }
//    return _tempPickerAlertView;
//}
//
//-(NSArray *)pickerViewData
//{
//    if (!_pickerViewData)
//    {
//        _pickerViewData = @[@"0",@"1",@"2",@"3",@"4",
//                              @"5",@"6",@"7",@"8",@"9",
//                              @"10",@"11",@"12",@"13",@"14",
//                              @"15",@"16",@"17",@"18",@"19",
//                              @"20",@"21",@"22",@"23",@"24",
//                              @"25",@"26",@"27",@"28",@"29",
//                              @"30",@"31",@"32",@"33",@"34",
//                              @"35",@"36",@"37",@"38",@"39",];
//    }
//    return _pickerViewData;
//}
//
//-(UIPickerView *)pickerView
//{
//    if (!_pickerView)
//    {
//        _pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(10, 0, 50, 100)];
//        [_pickerView setDataSource:self];
//        [_pickerView setDelegate:self];
//    }
//    return _pickerView;
//}
//#pragma -mark- UIPickerViewDataSource
//- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
//{
//    return 1;
//}
//
//- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
//{
//    return [self.pickerViewData count];
//}
//
//- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
//{
//    NSString *title = [self.pickerViewData objectAtIndex:row];
//    title = [title stringByAppendingString:@"度"];
//    return title;
//}
//
//#pragma -mark- UIAlertViewDelegate
//-(void)alertView:(UIAlertView *)alertView
//clickedButtonAtIndex:(NSInteger)buttonIndex
//{
//    if ([alertView isEqual:self.timePickerAlertView])
//    {
//        if (1 == buttonIndex)
//        {
//            switch (self.tempPickerAlertView.tag)
//            {
//                case 0:{
//                    DeviceSun * device = [DeviceSun defaultDevice];
//                    [_highTempButton setTitle:[NSString stringWithFormat:@"%ld度", (long)[self.pickerView selectedRowInComponent:0]]
//                                     forState:UIControlStateNormal];
//                    
//                    [[APIs sharedInstance] setHighOrLowTemperatureWithHigh:(NSInteger)[self.pickerView selectedRowInComponent:0] low:device.low password:device.password success:^{
//                        
//                        
//                    } failure:^(NSInteger errorCode) {
//                    }];
//
//                }
//                    break;
//                case 1:{
//                    DeviceSun * device = [DeviceSun defaultDevice];
//                    [_lowTempButton setTitle:[NSString stringWithFormat:@"%ld度", (long)[self.pickerView selectedRowInComponent:0]]
//                                    forState:UIControlStateNormal];
//                    
//                    [[APIs sharedInstance] setHighOrLowTemperatureWithHigh:device.high low:(NSInteger)[self.pickerView selectedRowInComponent:0] password:device.password success:^{
//                        
//                        
//                    } failure:^(NSInteger errorCode) {
//                    }];
//
//                }
//                    break;
//                default:
//                    break;
//            }
//        }
//    }
//}
//
//@end
